package com.service;

import com.data.DataService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.feign.LocalRecApiFeign;
import com.model.ProductRecResultVONewWithLocation;
import com.request.upload.RecResultRequest;
import com.response.Result;
import com.util.JsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UploadService {

    private static Logger logger = LoggerFactory.getLogger(UploadService.class);

    @Autowired
    LocalRecApiFeign localRecApiFeign;


    public void uploadRecResult(String fileContent, ProductRecResultVONewWithLocation productRecResultVONewWithLocation){
        RecResultRequest recResultRequest = new RecResultRequest();
        recResultRequest.setBranchId(DataService.branchId);
        recResultRequest.setShopId(DataService.shopId);
        recResultRequest.setFileContent(fileContent);
        recResultRequest.setDeviceId(DataService.deviceId);
        recResultRequest.setResult(productRecResultVONewWithLocation);

        try {
            logger.info("uploadRecResult========================================");
            Result result = localRecApiFeign.uploadRecResult(recResultRequest);
//            logger.info("uploadRecResult=======================================result=:{}", JsonUtil.toJson(result));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
